#include "rwmake.ch"
#include "colors.ch"
// Boletim do Requeijao
#IFNDEF WINDOWS
	#DEFINE PSAY SAY
#ENDIF

*********************************************
User Function AVI00098()
*********************************************
//mano_mes=STRZERO(MONTH(DDATABASE),2,0)+"/"+STR(YEAR(DDATABASE),5,0)
mConti:=space(6)
mContf:=Space(6)

SetPrvt("CCADASTRO,AROTINA,nOrd,cArea,nReg")
@ 0,0 to 140,220 Dialog oDlg Title "BOLETIM REQUEIJAO"

@ 15,05 Say "Controle IniciaL.: "
@ 15,70 Get mConti picture "@!"
@ 30,05 Say "Controle Final...: "
@ 30,70 Get mContF picture "@!"


@ 050,10 BMPBUTTON TYPE 1 ACTION IMP_PED()
@ 050,50 BMPBUTTON TYPE 2 ACTION Close(oDlg)
ACTIVATE DIALOG oDlg CENTER
Return


**********************************************
STATIC FUNCTION IMP_PED()
**********************************************
Local cStartPath := GetSrvProfString("Startpath","")
Close(oDlg)
set century on
cFileLogo 	:= cStartPath+ "packages"+".BMP" 			// Empresa+Filial
cBitMap:= cStartPath+ "vaca1"+".bmp" 			// Empresa+Filial

dbSelectArea("SZJ")
_filtro:="SZJ->ZJ_NUMERO       >='"+mConti+"'"
_filtro+=".AND. SZJ->ZJ_NUMERO  <='"+mContF+"'"
cind:=criatrab(nil,.f.)
cchave="SZJ->ZJ_FILIAL+SZJ->ZJ_NUMERO"
indregua("SZJ",cind,cchave,,_filtro,"Selecionando registros...")
dbGoTop()

oFont1:= TFont():New( "Arial",,10,,.T.,,.T.,,,.f. ) // Nome da Especie / Classification
oFont2:= TFont():New( "Arial",,10,,.F.,,,,,.f. ) // Nome da Especie / Classification
oFont3:= TFont():New( "Arial",,20,,.T.,,,,,.f. ) // Nome da Especie / Classification
oFont4:= TFont():New( "Arial",,12,,.T.,,,,,.f. ) // Nome da Especie / Classification
oFont5:= TFont():New( "Arial",,10,,.F.,,,,,.f. ) // Nome da Especie / Classification
oFont6:= TFont():New( "Arial",,11,,.T.,,,,,.f. ) // Nome da Especie / Classification
oFont7:= TFont():New( "Arial",,12,,.F.,,,,,.f. ) // Nome da Especie / Classification
oFont8:= TFont():New( "Courier",,12,,.T.,,,,,.f. ) // Nome da Especie / Classification
oFont9:= TFont():New( "Arial ",,08,,.F.,,,,,.f. ) // Nome da Especie / Classification
oFont10:= TFont():New( "samarin",,15,,.T.,,,,,.f. ) // Nome da Especie / Classification
oPrint:= TMSPrinter():New()
oBrush	:= TBrush():New(,CLR_HGRAY)
while !eof()                    //// Aqui comea o lao das linhas
	//	oPrint:SetPage(9) 			// Papel A4
	//	oPrint:SetPortrait() 		// Papel Paisagem
	oPrint:SetLandScape()
	oPrint:StartPage() 			// Inicia uma nova pagina
	wCol:=10
	wLin:=10
	_tam:=260;_larg:=3050
	oPrint:Box( wLin,wCol,wLin+_tam,wCol+_larg )		//Box - Logomarca / Cabealho
	oPrint:SayBitmap( wLin+010,wCol+10,cBitMap,530,230 )
	oPrint:say( wLin+15,wCol+590, "Razo Social: ",oFont2)
	oPrint:say( wLin+15,wCol+870, SM0->M0_NOMECOM,oFont2)
	oPrint:say( wLin+75,wCol+590, "CNPJ: ",oFont2)
	oPrint:say( wLin+75,wCol+730, Transform(SM0->M0_CGC,"@R 99.999.999/9999-99"),oFont1)
	oPrint:say( wLin+75,wCol+1390, "Inscrio Estadual: ",oFont2)
	oPrint:say( wLin+75,wCol+1780, InscrEst(),oFont1)
	oPrint:say( wLin+135,wCol+590, "Endereo: ",oFont2)
	oPrint:say( wLin+135,wCol+800, ALLTRIM(SM0->M0_ENDENT),oFont1)
	oPrint:say( wLin+135,wCol+1390, "Bairro: ",oFont2)
	oPrint:say( wLin+135,wCol+1530, ALLTRIM(SM0->M0_BAIRCOB),oFont1)
	oPrint:say( wLin+135,wCol+1890, "Cep: ",oFont2)
	oPrint:say( wLin+135,wCol+1985, Transform(SM0->M0_CEPENT,"@R 99999-999"),oFont1)
	oPrint:say( wLin+195,wCol+590, "Cidade: ",oFont2)
	oPrint:say( wLin+195,wCol+750, alltrim(SM0->M0_CIDENT)+" - "+SM0->M0_ESTENT,oFont1)
	oPrint:say( wLin+195,wCol+1390, "Fone: ",oFont2)
	oPrint:say( wLin+195,wCol+1530, SM0->M0_TEL,oFont1)
	oPrint:say( wLin+195,wCol+1890, "Fax: ",oFont2)
	oPrint:say( wLin+195,wCol+1985, SM0->M0_FAX,oFont1)

	_space:=35
	wLin+=(_space+_tam)
	_tam:=82;_larg:=3325
	oPrint:Box( wLin,wCol,wLin+_tam,wCol+_larg )		//Box - Ordem de Compra
	oPrint:say( wLin+02,wCol+1350, "BOLETIM REQUEIJAO"  ,oFont3)
	oPrint:say( wLin+90,wCol+0010, "Codigo do Produto:",oFont1)
	oPrint:say( wLin+90,wCol+450, SZJ->ZJ_CODPR2 ,oFont2) //leite
	oPrint:say( wLin+125,wCol+010, "DESCRICAO:",oFont1)
	oPrint:say( wLin+125,wCol+450, SZJ->ZJ_NOMPRO2 ,oFont2)
   	oPrint:say( wLin+160,wCol+010, "Acidez: ",oFont1)
	oPrint:say( wLin+160,wCol+450, Transform(SZJ->ZJ_ACIDEZ1, "@E 9,999.99") ,oFont2)
	oPrint:say( wLin+200,wCol+010, "PH: ",oFont1)
	oPrint:Say( wLin+200,wCol+450,Transform(SZJ->ZJ_PH1,"@!",),	oFont2)
	oPrint:say( wLin+240,wCol+010, "Gordura:",oFont1)
	oPrint:say( wLin+240,wCol+410, Transform(SZJ->ZJ_GORD1,"@e 9999.99") ,oFont2)
	oPrint:say( wLin+280,wCol+0010, "Densidade:",oFont1)
	oPrint:say( wLin+280,wCol+410, Transform(SZJ->ZJ_DENSID2, "@e 9999.99") ,oFont2)
	oPrint:say( wLin+090,wCol+1100, "Codigo Mat prima:",oFont1)
	oPrint:say( wLin+090,wCol+1480, SZJ->ZJ_MPRIMA1 ,oFont2)
	oPrint:say( wLin+125,wCol+1100, "Descricao:",oFont1)
	oPrint:say( wLin+125,wCol+1480, SZJ->ZJ_NOMMP3,oFont2)
	oPrint:say( wLin+160,wCol+1100, "ACIDEZ2:",oFont1)
	oPrint:say( wLin+160,wCol+1480, Transform(SZJ->ZJ_ACIDEZ2, "@e 9999.99") ,oFont2)
	oPrint:say( wLin+200,wCol+1100, "PH:",oFont1)
	oPrint:say( wLin+200,wCol+1480, Transform(SZJ->ZJ_PH2,"@e 9999.99") ,oFont2)
	oPrint:say( wLin+240,wCol+1100, "GORDURA2:",oFont1)
	oPrint:say( wLin+240,wCol+1480, Transform(SZJ->ZJ_GORD2,"@e 9999.99") ,oFont2)
	oPrint:say( wLin+090,wCol+2000, "CODIGO PRODUTO:",oFont1)
	oPrint:say( wLin+090,wCol+2250, SZJ->ZJ_CODPRO3 ,oFont2)
	oPrint:say( wLin+125,wCol+2000, "DESCRICAO:",oFont1)
	oPrint:say( wLin+125,wCol+2250, SZJ->ZJ_MPRIMA3 ,oFont2)
	oPrint:say( wLin+160,wCol+2000, "GORDURA:",oFont1)
	oPrint:say( wLin+160,wCol+2250, Transform(SZJ->ZJ_GORD3,"@e 9999.99") ,oFont2)
	oPrint:say( wLin+200,wCol+2000, "PH3:",oFont1)
	oPrint:say( wLin+200,wCol+2250, Transform(SZJ->ZJ_PH3,"@e 9999.99") ,oFont2)
	oPrint:say( wLin+240,wCol+2000, "UMIDADE1:",oFont1)
	oPrint:say( wLin+240,wCol+2250, Transform(SZJ->ZJ_UMID2,"@e 9999.99") ,oFont2)
    oPrint:say( wLin+090,wCol+2650, "Codigo Produto:",oFont1)
	oPrint:say( wLin+090,wCol+2950, SZJ->ZJ_NUMERO,oFont2)
	oPrint:say( wLin+125,wCol+2650, "Data de fabricacao:",oFont1)
	oPrint:say( wLin+125,wCol+2950, DTOC (SZJ->ZJ_FABRIC) ,oFont2)
	oPrint:say( wLin+160,wCol+2650, "Quantidade:",oFont1)
	oPrint:say( wLin+160,wCol+2950, Transform(SZJ->ZJ_QUANT, "@E 99,999,999.999"),oFont2)
	
	
	
	wLin+=175
	
	wLin+=50
	dbSelectArea("SZL")
	dbSetOrder(1)
	dbSeek(xFilial()+SZJ->ZJ_NUMERO)
	WHILE !EOF() .And. ZL_NUMERO  == SZJ->ZJ_NUMERO
		wLin+=50
		oPrint:Box( wLin+101,wCol,wLin+150,wCol+3325 )		    //Box - Cabealho Itens - Pedido
		oPrint:FillRect({wlin+101,0005,WLIN+150,3000},oBrush)
		oPrint:say( wLin+110,wCol+0010, "ITEM" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+0260, "LOTE",oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+0400, "DATA" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+0600, "COR" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+0800, "SABOR" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+1050, "ODOR" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+1300, "APRESENTACAO" ,oFont2,,CLR_BLUE)
  		oPrint:say( wLin+110,wCol+1650, "UMIDADE" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+1850, "EST" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+2000, "ESD" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+2200, "PH" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+2400, "NACI" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+2600, "GES" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+110,wCol+2800, "COLIFORMES" ,oFont2,,CLR_BLUE)
		wLin+=50
		oPrint:Box( wLin+151,wCol,wLin+200,wCol+3325 )    
		oPrint:FillRect({wlin+155,0005,WLIN+200,3000},oBrush)
		oPrint:say( wLin+160,wCol+0010, "BOLORES" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+0200, "COLGEM" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+0400, "GERMES" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+0600, "LEVEDURA" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+0800, "ECOLI",oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+1000, "GORDURA" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+1200, "ACIDEZ" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+1400, "DENSIDADE" ,oFont2,,CLR_BLUE)            
		oPrint:say( wLin+160,wCol+1650, "CONSISTENCIA" ,oFont2,,CLR_BLUE)
		oPrint:say( wLin+160,wCol+2000, "TEXTURA" ,oFont2,,CLR_BLUE) 
		oPrint:say( wLin+160,wCol+2300, "CODIGO: " + SZL->ZL_CODIGO ,oFont2,,CLR_GREEN) 
		oPrint:say( wLin+200,wCol+2300, "PRODUTO: "+ SZL->ZL_PRODUTO ,oFont2,,CLR_GREEN) 
		
		
		
		wLin+=50
		oPrint:Say(wLin+50,wCol+010,Transform(SZL->ZL_ITEM,"@!"),oFont9)
		oPrint:Say(wLin+50,wCol+250,Transform(SZL->ZL_LOTE,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+50,wCol+400,DTOC(SZL->ZL_DATA),oFont9)
		if SZL->ZL_COR ="1"
			oPrint:Say(wLin+50,wCol+590,"Branco       ",oFont9)
		ELSEIF SZL->ZL_COR ="2"
			oPrint:Say(wLin+50,wCol+590,"Amarelo      ",oFont9)
		ELSEIF SZL->ZL_COR ="3"
			oPrint:Say(wLin+50,wCol+590,"Amarelo Palido",oFont9)
		ELSEIF SZL->ZL_COR ="4"
			oPrint:Say(wLin+50,wCol+590,"Esbranquicado",oFont9)
		ELSEIF SZL->ZL_COR ="5"
			oPrint:Say(wLin+50,wCol+590,"Castanho car.",oFont9)
		endif
		if SZL->ZL_SABOR="1"
			oPrint:Say(wLin+50,wCol+760,"Levemente Acido  ",oFont9)
		ELSEIF SZL->ZL_SABOR ="2"
			oPrint:Say(wLin+50,wCol+760,"Levemente picante",oFont9)
		ELSEIF SZL->ZL_SABOR ="3"
			oPrint:Say(wLin+50,wCol+760,"Picante          ",oFont9)
		ELSEIF SZL->ZL_SABOR ="4"
			oPrint:Say(wLin+50,wCol+760,"Caracteristico   ",oFont9)
		ELSEIF SZL->ZL_SABOR ="5"
			oPrint:Say(wLin+50,wCol+760,"Suave            ",oFont9)
		ELSEIF SZL->ZL_SABOR ="6"
			oPrint:Say(wLin+50,wCol+760,"Levemente suave  ",oFont9)
		endif
		oPrint:Say(wLin+50,wCol+1000,"Caracteristico",oFont9)
		if SZL->ZL_APRES ="1"
			oPrint:Say(wLin+50,wCol+1400,"Boa",oFont9)
		ELSEIF SZL->ZL_APRES ="2"
			oPrint:Say(wLin+50,wCol+1400,"Ruim",oFont9)
		ENDIF
		IF SZL->ZL_TEXTURA ="1"
			oPrint:Say(wLin+150,wCol+2000,"Lisa,uniforme,untosa",oFont9)
		ELSEIF SZL->ZL_TEXTURA =" "
			oPrint:Say(wLin+150,wCol+2000,"",oFont9)
		ENDIF
		oPrint:Say(wLin+50,wCol+1660,Transform(SZL->ZL_UMIDADE,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+50,wCol+1800,Transform(SZL->ZL_EST,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+50,wCol+1950,Transform(SZL->ZL_ESD,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+50,wCol+2150,Transform(SZL->ZL_PH,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+50,wCol+2350,Transform(SZL->ZL_NACI,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+50,wCol+2550,Transform(SZL->ZL_GES,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+50,wCol+2800,Transform(SZL->ZL_COLIF,"@e 999999.99"),oFont9)
		wLin+=50
		oPrint:Say(wLin+100,wCol+0050,Transform(SZL->ZL_BOLORES	,"@e 9999.99"),oFont9)
		oPrint:Say(wLin+100,wCol+0200,Transform(SZL->ZL_COLGERM,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+100,wCol+0400,Transform(SZL->ZL_GERMES,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+100,wCol+0600,Transform(SZL->ZL_LEVEDUR,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+100,wCol+0800,Transform(SZL->ZL_ECOLI,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+100,wCol+1000,Transform(SZL->ZL_GORDURA,"@e 9999.99"),oFont9)
		oPrint:Say(wLin+100,wCol+1200,Transform(SZL->ZL_ACIDEZ,"@e 999999.99"),oFont9)
		oPrint:Say(wLin+100,wCol+1400,Transform(SZL->ZL_DENSIDA,"@e 999999.99"),oFont9)
		If SZL->ZL_CONSIST="1"
			oPrint:Say(wLin+100,wCol+1650,"UNTOSA",oFont9)
		ElseIF	 SZL->ZL_CONSIST="2"
			oPrint:Say(wLin+100,wCol+1650,"PASTOSA NORMAL",oFont9)
		ElseIf SZL->ZL_CONSIST="3"
			oPrint:Say(wLin+100,wCol+1650,"PASTOSA MOLE",oFont9)
		Endif
	
		//   wlin+=100
		//		 oPrint:line(wLin+50,wCol+0010,wLin+50,wCol+3325 )		//Linha de Colunas do desconto
		
		skip
		
		loop
		
	END
	wLin+=50
	
	oPrint:Box ( wLin+100,wCol,wLin+300,wCol+3325 )		//Box - RODAPE
	oPrint:line( wLin+100,wCol+810,wLin+300,wCol+810 )			//Linha de Separao
	oPrint:line( wLin+100,wCol+1590,wLin+300,wCol+1590 )			//Linha de Separao
	oPrint:line( wLin+200,wCol+70,wLin+200,wCol+750 )			//Linha de Separao*/
	oPrint:say( wLin+200,wCol+150, "Controle de qualidade",oFont4)
	oPrint:line( wLin+200,wCol+880,wLin+200,wCol+1500 )			//Linha de Separao*/
	oPrint:say( wLin+200,wCol+910, "Analista Laboratorio ",oFont4)
	//	oPrint:line( wLin+200,wCol+1700,wLin+200,wCol+3100+_tam )			//Linha de Separao*/
	oPrint:say( wLin+100,wCol+1630, "Observacao data",oFont4)
	
	oPrint:EndPage() 		// Finaliza a pagina
	
	// Aqui terminou o a impresso do primeiro forncedor
	
	dbSelectArea("SZJ")  // volta para arquivo de linhas
	skip		     // vai pegar prximo registro de linhas
	loop
enddo

oPrint:Preview()
oPrint:EndPage() 		// Finaliza a pagina
dbSelectArea("SZJ")
dbCloseArea()
set century off
return
